<%-- 
    Document   : sign-up-process
    Created on : Aug 24, 2011, 12:40:51 PM
    Author     : Administrator
--%>

<%@page import="dao.KhachHangDAO"%>
<%@page import="pojo.KhachHangPOJO"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>

<% 
    //Set chọn lấy thông tin utf-8
    request.setCharacterEncoding("UTF-8");
    response.setCharacterEncoding("UTF-8");
    response.setContentType("text/html;charset=UTF-8");
    
    //Lấy thông tin đăng ký
    KhachHangPOJO kh = new KhachHangPOJO();
    kh.setTenDangNhap(request.getParameter("tfTenDangNhap"));
    kh.setMatKhau(request.getParameter("tfMatKhau"));
    kh.setHoTen(request.getParameter("tfHoTen"));
    kh.setDiaChi(request.getParameter("tfDiaChi"));
    kh.setEmail(request.getParameter("tfEmail"));
    
    boolean kq = KhachHangDAO.themKhachHang(kh);
    if (kq == true){
        out.println("Đăng ký thành công");
        //Tạo session cho người dùng.
        session.setAttribute("KhachHang", kh);

        //Chuyển qua qua trang chủ.
        String url = request.getContextPath()+"/index.jsp";
        response.sendRedirect(url);
    }else{
        out.println("Đăng ký thất bại");
        //Chuyển qua qua trang chủ.
        String url = request.getContextPath()+"/client/sign-up.jsp";
        response.sendRedirect(url);
    }
%>
